package university.dropcourse.resource;

import javax.ejb.EJB;
import javax.ejb.Stateless;
import javax.ws.rs.Consumes;
import javax.ws.rs.FormParam;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import university.dropcourse.dto.DocenteDto;
import university.dropcourse.dto.StudenteDto;
import university.dropcourse.service.LoginManagerBean;


@Stateless
@Path(value="login")
public class LoginManagerDelegator {

    @EJB
    LoginManagerBean loginBean;


    public LoginManagerDelegator() { }


    @POST
    @Path("loginDocente")
    @Consumes(MediaType.APPLICATION_FORM_URLENCODED)
    @Produces(MediaType.APPLICATION_XML)
    public DocenteDto verificaDocente(@FormParam("matricola") String matricola,
    		@FormParam("password") String password) {
    	System.out.print("matrDoc: "+matricola+" pass: "+password);
        return loginBean.verificaDocente(matricola, password);
        
    }
    
    @POST
    @Path("loginStudente")
    @Consumes(MediaType.APPLICATION_FORM_URLENCODED)
    @Produces(MediaType.APPLICATION_XML)
    public StudenteDto verificaStudente(@FormParam("matricola") String matricola,
    		@FormParam("password") String password) {
    	
    	System.out.print("matrStud: "+matricola+" pass: "+password);
        return loginBean.verificaStudente(matricola, password);
        
    }
}